package com.wang.lotterysystem.dao.mapper;

import com.wang.lotterysystem.dao.dataobject.activity.ActivityDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {
    @Insert("insert into activity (activity_name, description, status) " +
            "VALUES (#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    int insert(ActivityDO activityDO);

    @Select("select count(1) from activity")
    int count();

    @Select("select id, gmt_create, gmt_modified, activity_name, description, status from activity " +
            "order by id desc " +
            "limit #{pageSize} offset #{offset}")
    List<ActivityDO> queryActivitiesByPage(Integer offset,Integer pageSize);

    @Select("select id, gmt_create, gmt_modified, activity_name, description, status" +
            " from activity where id = #{activityId}")
    ActivityDO selectById(Long activityId);

    @Update("update activity set status = #{status} " +
            "where id = #{activityId}")
    void convert(Long activityId,String status);
}